package com.demon.encrypt.lock;

/**
 * @author Rao
 * @Date 2020/6/16
 * 不可重入锁
 **/
public class NonReentrantLock {

    private boolean isLocked = false;
    public synchronized void lock() throws InterruptedException{
        while(isLocked){
            wait();
        }
        isLocked = true;
    }
    public synchronized void unlock(){
        isLocked = false;
        notify();
    }

}
